#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   search_result_test.py    
@Contact :   pengwei.sun@aihuishou.com
@License :   (C)Copyright aihuishou

@Modify Time      @Author       @Version    @Desciption
------------      -----------   --------    -----------
2022-01-05 15:38   pengwei.sun      1.0         None
'''
import os
import sys
sys.path.append(os.getcwd())
from src.utils.config import logger
from src.mobile.levelrate.reverse.sku2_skulevel_period_price import get_period_price_fun
from src.mobile.levelrate.reverse.function_utils import save_pickle_data,load_pickle_data,check_conflict_file
import pickle
from src.mobile.levelrate.reverse.sku2_common_variable import  FILE_DIR
import pandas as pd
# process_df=pd.read_csv('/data/sunpengwei/tmp/sku2_price_detail.csv',index_col=0)
# 6609739
# period_data = get_period_price_fun('2022-02-23', flag=True)

sku2_price_level_reverse_process1_data = load_pickle_data(FILE_DIR + 'sku2_price_level_reverse_process1_data_tablet.pkl')
result_price_tablet_df = load_pickle_data(FILE_DIR + 'result_price_tablet_df.pkl')
level_p_df=pd.read_csv('/data/sunpengwei/tmp/product_price_level2_rate_config_tablet_v1.csv')
# save_pickle_data(FILE_DIR + 'sku2_price_property_reverse_calculation_process2_df.pkl', result)
# result = load_pickle_data(FILE_DIR +'sku2_price_property_reverse_calculation_process2_df.pkl')
# reverse_df1 = load_pickle_data(FILE_DIR + 'sku2_price_property_reverse_calculation_process2_df_tablet.pkl')
# sku2_price_property_process4_data_calculation2 = load_pickle_data(FILE_DIR + 'sku2_price_property_process4_data_calculation2_tablet.pkl')
# sku2_price_reverse2_process3_data = load_pickle_data(FILE_DIR + 'sku2_price_reverse2_process3_data_tablet.pkl')
#
# fetch_df = load_pickle_data(FILE_DIR + 'sku2_price_fetch_process_data_tablet.pkl')
# process_df1=pd.read_csv(FILE_DIR + 'sku2_final_price_tablet.csv',index_col=0)
tmp1 = sku2_price_level_reverse_process1_data[['product_brand_id', 'product_brand_name',  'product_category_id', 'product_category_name', 'product_key', 'product_level_id', 'product_level_key', 'product_level_name_tmp', 'product_name', 'product_sku_key', 'product_sku_name', 'qty', 'rank', 'rank_tmp', 'reverse_cnt', 'sale_num','price_0_3', 'sale_num_0_3','product_level_name', 'process_price','price_0_7','sale_num_0_7', 'sale_num_15_21','sale_num_22_42', 'sale_num_8_14', 'saleprice','saleprice_level_price_rate', 'saleprice_tmp', 'score','second_base_level_price', 'second_level_name', 'second_level_rate', 'second_template_rank', 'sku_cnt', 'sumprice', 'template_rank','thisprice', 'updated_at', 'weight_cnt']]
tmp1['diff'] = tmp1['process_price']-tmp1['price_0_7']
tmp1['diff_abs'] = abs(tmp1['process_price']-tmp1['price_0_7'])
tmp1.loc[tmp1.price_0_7>0].sort_values(by='diff_abs',ascending=False)

level_p_df['diff'] = level_p_df['process_price']-level_p_df['price_0_7']
level_p_df['diff_abs'] = abs(level_p_df['process_price']-level_p_df['price_0_7'])
level_p_df.loc[level_p_df.price_0_7>0].sort_values(by='diff_abs',ascending=False)
logger.info('dss')

